package cn.iocoder.yudao.module.moa.service.qjapplysub;

import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;
import cn.iocoder.yudao.module.moa.controller.admin.qjapplysub.vo.*;
import cn.iocoder.yudao.module.moa.dal.dataobject.qjapplysub.QjApplySubDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import cn.iocoder.yudao.module.moa.dal.mysql.qjapplysub.QjApplySubMapper;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;


/**
 * MOA 请假关联 Service 实现类
 *
 * @author 管理员
 */
@Service
@Validated
public class QjApplySubServiceImpl implements QjApplySubService {

    @Resource
    private QjApplySubMapper qjApplySubMapper;

    @Override
    public Long createQjApplySub(QjApplySubSaveReqVO createReqVO) {
        // 插入
        QjApplySubDO qjApplySub = BeanUtils.toBean(createReqVO, QjApplySubDO.class);
        qjApplySubMapper.insert(qjApplySub);
        // 返回
        return qjApplySub.getId();
    }

    @Override
    public void updateQjApplySub(QjApplySubSaveReqVO updateReqVO) {
        // 校验存在
        validateQjApplySubExists(updateReqVO.getId());
        // 更新
        QjApplySubDO updateObj = BeanUtils.toBean(updateReqVO, QjApplySubDO.class);
        qjApplySubMapper.updateById(updateObj);
    }

    @Override
    public void deleteQjApplySub(Long id) {
        // 校验存在
        validateQjApplySubExists(id);
        // 删除
        qjApplySubMapper.deleteById(id);
    }

    private void validateQjApplySubExists(Long id) {
        if (qjApplySubMapper.selectById(id) == null) {
        }
    }

    @Override
    public QjApplySubDO getQjApplySub(Long id) {
        return qjApplySubMapper.selectById(id);
    }

    @Override
    public PageResult<QjApplySubDO> getQjApplySubPage(QjApplySubPageReqVO pageReqVO) {
        return qjApplySubMapper.selectPage(pageReqVO);
    }

}
